<template>
	<view>
		<remind-carinfo :dataBean="dataBean"></remind-carinfo>

		<view class="item" style="padding: 0 20rpx;">

			<u-icon name="order" color="#1573FF" label="收车" label-color="#333333"
				:customStyle="{'line-height': '80rpx','display': 'block','padding-left':'20rpx',}"></u-icon>

			<u-line color="#efefef" :customStyle="{'margin-bottom': '10rpx','display': 'block',}"></u-line>

			<u-form :model="addbean" ref="uform" label-width="auto">

				<u-form-item label="档案名称" borderBottom required>
					<u-input v-model="addbean.recordName" inputAlign="right" border="none" placeholder="请输入档案名称">
					</u-input>
				</u-form-item>

				<u-form-item label="备注" borderBottom >
					<u-input v-model="addbean.remark" inputAlign="right" border="none" placeholder="请输入备注">
					</u-input>
				</u-form-item>

				<text style="padding: 20rpx 0; display: block;font-size: 30rpx;color: #333;">附件</text>

				<lr-upload @on-change='onListChange' :tag="1" objType="11"></lr-upload>

			</u-form>
		</view>

		<examflow :from="pageType" :instanceId="instanceId" approvalName="carCollectApprove" :isAdd="'add'==pageType">
		</examflow>

		<!-- 原因 -->
		<u-picker :show="reasonShow" :columns="reasonList" keyName="value" @confirm="pickerConfim"
			@cancel="reasonShow=false"></u-picker>

		<!-- 时间 -->
		<u-datetime-picker :show="timeShow" mode="date" @confirm="timeconfirm" @cancel="timeShow=false">
		</u-datetime-picker>

		<view style="height: 100rpx;"></view>

		<view class="button-container">
			<button class="btn-item" @click="commit">提 交</button>
		</view>

	</view>
</template>

<script>
	import remindCarinfo from '@/components/remind-carinfo.vue';
	import lrUpload from '@/components/global/lr-upload.vue';
	import examflow from '@/components/exam-flow.vue';

	export default {
		components: {
			remindCarinfo,
			lrUpload,
			examflow
		},
		data() {
			return {
				carCode: '',
				vehicle: {},
				addbean: {
					remark: '',
					attachment: [],
					recordName:'',
					carCode:'',
					uploadTime:'',
				}
			}
		},
		computed: {
			dataBean() {
				return {
					vehicle: this.vehicle
				}
			}
		},
		methods: {

			onListChange(tag, list, objList) {

				console.log('结果list', list);
				console.log('结果objList', objList);

				// if (tag == 1) {
				this.addbean.attachment = objList;
				// }

			},

			commit() {
				if (uni.$u.test.isEmpty(this.addbean.recordName)) {
					this.$u.toast('请输入档案名称');
					return
				}
				
				this.addbean.uploadTime = uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd hh:MM:ss')

				let that = this;

				uni.showModal({
					content: '确定提交吗？',
					success(res) {
						if (res.confirm) {
							
							that.$u.api.carArchivesSave(that.addbean).then(
								res => {
									uni.showToast({
										title: '提交成功',
										icon: 'none'
									});
									setTimeout(()=>{
										uni.navigateBack()
									}, 1000)
								}
							);


						}
					}
				})
			}

		},
		onLoad(op) {
			this.carCode = op.carCode;
			this.vehicle = getApp().globalData.profile_vehicle;
			
			getApp().globalData.profile_vehicle = {}
			
			this.addbean.carCode = this.carCode;


		}
	}
</script>

<style lang="scss" scoped>
	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;
		z-index: 999;
		background-color: white;
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 98%;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 50rpx;
			background-color: $blue15;
			color: white;
			text-align: center;
			font-size: 30rpx;
		}
	}
</style>
